<template>
    <div id="app">
        <hb-head headfont="余额充值"></hb-head>
        <div class="mui-content">

            <ul class="slg mui-table-view mui-table-view-chevron">
                <li v-for="item in recharge_card" class="mui-table-view-cell mui-media" style="text-align: left;" @tap.prevent.stop="goRecharge(item.money/100)">
                    <a href="#" class="mui-navigate-right">
                        <div class="mui-media-body">
                            {{ item.money / 100 }}元(赠送积分{{item.score / 100}})
                        </div>
                    </a>
                </li>
            </ul>
        </div>
         <order-list :activeCategory="activeCategory"></order-list> 
    </div>
</template>

<script>

import { ajax, userSettings, userRedirect, callWechatPay } from 'assets/js/Lib'

import 'assets/css/mui.css'

import HbHead from 'components/HbHead'
import NavBarTab from 'components/NavBarTab'
import OrderList from 'components/OrderList'

export default {
    data() {
        return {
            recharge_card: [],
        }
    },
    components: {
        HbHead, NavBarTab, OrderList
    },
    computed: {

    },
    //实例初始化最之前，无法获取到data里的数据
    beforeCreate() {

    },
    //在挂载开始之前被调用
    beforeMount() {

    },
    //已成功挂载，相当ready()
    mounted() {

        const vm = this;
        ajax({
            url: '/api/user/recharge_card',
            type: 'GET',
            success: (res) => {
                vm.recharge_card = res
            }
        })

        mui.init({
            statusBarBackground: '#f7f7f7'
        })
    },
    //相关操作事件
    methods: {
        goRecharge(money) {
            ajax({
                url: '/api/user/recharge',
                type: 'POST',
                data: {
                    money,
                    payment_id: 2,
                },
                success: (url) => {
                    console.log('res', url);
                    ajax({
                        url: url,
                        type: 'GET',
                        success: (res) => {
                            callWechatPay(res, null);
                        }
                    })
                }
            })


        },
    }
}
</script>

<style lang="less">
.content-banner {
    height: 60px;
}

.text-button {
    width: 24.99%;
    height: inherit;
    float: left;
    padding: 15px;
    cursor: pointer;

    &:active {
        background: #eee;
    }

    span {
        display: block;
        font-size: 12px;
        line-height: 12px;
        color: #232326;
        text-align: center;
    }

    span.header-text {
        font-size: 16px;
        line-height: 16px;
        margin-bottom: 6px;
    }
}

.img-button {
    width: 33.33%;
    height: inherit;
    float: left;
    padding: 15px;
    cursor: pointer;

    &:active {
        background: #eee;
    }

    img {
        width: 100%;
        height: 100%;
    }

    span.button-header {
        width: 21px;
        height: 18px;
        margin: 0 auto;
        margin-bottom: 4px;
        position: relative;
        display: block;

        .mui-badge {
            position: absolute;
            right: -15px;
            top: -10px;
        }
    }

    span.button-footer {
        display: block;
        font-size: 11px;
        line-height: 11px;
        color: #232326;
        text-align: center;
        margin-bottom: 4px;
    }
}

#app {

    img.slg {
        width: 15px;
        height: 18px;
    }

    .mui-table-view~.mui-card {
        margin-top: -2px;
    }

    .mui-table-view-cell {
        &:after {
            left: 0px;
        }
    }

    .mui-navigate-right {
        padding: 10px 65px 10px 11px;
        font-size: 14px;
        min-height: 32px;
    }

    .mui-navigate-right>.text {
        color: #bbb;
        right: 35px;
        position: absolute;
        top: 28%;
    }

    .mui-card {
        margin: 15px 0 10px 0;
        border-radius: 0px;
        box-shadow: 0 0px 1px rgba(0, 0, 0, .3);
    }

    .mui-table-view {
        /*margin-top: 25px;*/
    }
}
</style>
